package com.yiwyn.async.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

@Slf4j
@Service
public class TaskService {


    @Async
    public CompletableFuture<String> hello() throws InterruptedException {
        log.info("开始异步任务");

        TimeUnit.SECONDS.sleep(2);

        return CompletableFuture.completedFuture("定时任务");
    }


}
